#include<bits/stdc++.h>
using namespace std;
struct node{
    int x,y;//x1 y2;
};
map<int,node>m;
map<int,bool>m2;
int inp=0;
priority_queue<int,vector<int>,greater<int>>q;
int ans=0;
long long li=0;
int main(){
    //priority_queue(int,vector<int>,greater<int>)q;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("a.in","r",stdin);
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;
    int maxx=-1;
    cin>>n;
    ans=0;
    for(int i = 1;i<=n;i++){
        cin>>inp;
        if(m2[inp]==false){
            q.push(inp);
            m2[inp]=true;
        }
        m[inp].x++;
        m[inp].y++;
    }
    while(q.empty()==false){
        int now=q.top();
        q.pop();
        //kill
        if(li>0 and m[now].y!=0){
            if(li>m[now].y){
                li-=m[now].y;
            }
            else{
                li=0;
            }
        }
        //be killed
        bool flag=false;
        while(q.empty()==false and flag==false){
            if(m[now].x>m[q.top()].y){
                //cout<<q.top()<<"2>"<<now<<" "<<m[q.top()].y<<qr.size()<<endl;
                m[now].x-=m[q.top()].y;
                //cout<<q.top()<<"empty"<<endl;
                li+=m[q.top()].x;
                q.pop();
            }
            if(m[now].x>=0 and m[q.top()].y>=m[now].x  and q.empty()==false){
                //cout<<q.top()<<">2"<<now<<" "<<m[now].x<<qr.size()<<endl;
                flag=true;
                m[q.top()].y-=m[now].x;

            }
        }
        if(flag==false){
            //cout<<"uwhfwjf";
            li+=m[now].x;
            break;
        }
    }

    cout<<li;
    return 0;
}
